package cn.stacey.spring.ssm.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import cn.stacey.spring.ssm.domain.Category;
import cn.stacey.spring.ssm.exception.ServiceException;
import cn.stacey.spring.ssm.service.CategoryService;

@Controller
public class CategoryController {
	@Autowired
	CategoryService service;
	
	@RequestMapping("/category/delete")
	public void delete(int id) {
try {
		service.deleteCategory(id);
	}catch(DataIntegrityViolationException e){}
		//把异常做一个业务层转换，把数据库层的错误转换为业务错误
	throw new ServiceException(20001,"分类已经关联文章，不能删除");
	}
	
	

	
}
